 /**
 * @file tal_heartbeat.h
 * @brief Common process - heartbeat report
 * @version 1.0.0
 * @date 2021-10-09
 *
 * @copyright Copyright 2018-2021 Tuya Inc. All Rights Reserved.
 *
 */
#ifndef __TAL_HEARTBEAT_H__
#define __TAL_HEARTBEAT_H__


#ifdef __cplusplus
    extern "C" {
#endif

#include "tuya_cloud_types.h"
#include "tuya_zigbee_stack.h"


/**
 * @enum the type of the heartbeat
 */
typedef enum {
    HEARTBEAT_APP_VERSION = 0,  ///< reported version number
    HEARTBEAT_BATTERY_VOLTAGE,  ///< report battery information
} TAL_HEARTBEAT_TYPE_E;

/**
 * @brief heartbeat struct
 */
typedef struct {
    TAL_HEARTBEAT_TYPE_E type;  ///< heartbeat type
    UINT_T period;              ///< heartbeat period(bat:ms)
} TAL_HEARTBEAT_T;


/**
 * @brief Enter first status about heartbeat reporting.
 * 
 * @param[in]   none
 *
 * @return none
 */
VOID_T tal_heartbeat_reset(VOID_T);

/**
 * @brief start period heartbeat sending
 * 
 * @param[in]   none
 *
 * @return none
 */
VOID_T tal_heartbeat_start(VOID_T);

/**
 * @brief stop period heartbeat sending
 * 
 * @param[in]   none
 *
 * @return none
 */
VOID_T tal_heartbeat_stop(VOID_T);

/**
 * @brief set period of heartbeat 
 * 
 * @param[in]   time_ms: heartbeat period (bat: ms)
 *
 * @return none
 */
VOID_T tal_heartbeat_period_set(UINT_T time_ms);

/**
 * @brief set type of heartbeat 
 * 
 * @param[in]   type: heartbeat type
 *
 * @return none
 */
VOID_T tal_heartbeat_type_set(TAL_HEARTBEAT_TYPE_E type);

/**
 * @brief heartbeat report callback
 * @note < this is a weak function you can rewrite this API in app layer >
 * 
 * @param[in]   type: heartbeat type
 *
 * @return none
 */
VOID_T tal_heartbeat_report_callback(TAL_HEARTBEAT_TYPE_E type);


#ifdef __cplusplus
}
#endif

#endif

